<template>
  <div>
    城市
    <div id="main" style="width: 320px; height: 500px; margin: 0 auto"></div>
  </div>
</template>

<script>
export default {
  mounted() {
    // console.log(this.$route.params.city);
    // this.$chart.cityMap('main')
    this.$api
      .cityData({
        city: this.$route.params.city,
      })
      .then((res) => {
        // console.log(res.data.retdata.subList);
        let arr = [];
        res.data.retdata.subList.forEach((element) => {
          let temp = {};
          //城市内部对应的区域名称： 郑州市  朝阳区
          var reg = /北京|上海|天津/;
          if(reg.test(this.$route.params.city)){
               temp.name = element.city;
          }else{
              temp.name = element.city+'市'
          }
          temp.value = element.confirm;
          //追加数组
          arr.push(temp);
        });
        //显示地图
        console.log(arr);
        this.$chart.cityMap("main",this.$route.params.city,arr);
      });
  },
};
</script>

<style>
</style>